﻿using AutoMapper;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using WMS.FC.Domain.DomainObject.System;
using WMS.FC.Domain.DomainObject.Technology;
using WMS.FC.Domain.Repository;
using WMS.FC.Domain.Service.System;
using WMS.FC.Domain.Service.Technology.Interface;

namespace WMS.FC.Domain.Service.Technology
{
    public class GetTechnologyReouteListService : ServiceBase, IGetTechnologyReouteListService
    {
        protected readonly ITechnologyRepository technologyRepository;

        public GetTechnologyReouteListService(
            ILogger<ServiceBase> logger,
            IOptions<WmsSettings> options,
            IMapper mapper,
            ITechnologyRepository technologyRepository)
            : base(logger, options, mapper)
        {
            this.technologyRepository = technologyRepository;
        }

        public async Task<ActionResult<List<TechnologyRouteDO>>> GetTechnologyReouteList(UserInfo userInfo)
        {
            var result = new ActionResult<List<TechnologyRouteDO>>("获取工艺路径列表");
            try
            {
                var technologyRoutePOList = await technologyRepository.GetAllTechnologyRouteList();
                result.Data = mapper.Map<List<TechnologyRouteDO>>(technologyRoutePOList);
            }
            catch (Exception ex)
            {
                return result.Exception(ex);
            }

            return result;
        }
    }
}
